<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\CustomerXStaff
 *
 * @property int $id
 * @property int $customer_clues_id 客户线索id
 * @property int $staff_id 跟进的员工id
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerXStaff newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerXStaff newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\CustomerXStaff onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerXStaff query()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerXStaff whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerXStaff whereCustomerCluesId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerXStaff whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerXStaff whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerXStaff whereStaffId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerXStaff whereUpdatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\CustomerXStaff withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\CustomerXStaff withoutTrashed()
 * @mixin \Eloquent
 */
class CustomerXStaff extends Model
{
    use SoftDeletes;

    public static function getCustomerNowStaff($clue_id){
        if (!$clue_id)
            return null;
        $result = [];
        $data = self::whereCustomerCluesId($clue_id)
            ->orderByDesc('id')
            ->first();
        if ($data){
             return Staff::whereId($data->staff_id)->first();
        }
        return null;
    }
}
